package com.leo;

import com.almasb.fxgl.app.GameApplication;
import com.almasb.fxgl.app.GameSettings;
import com.almasb.fxgl.app.scene.FXGLMenu;
import com.almasb.fxgl.app.scene.LoadingScene;
import com.almasb.fxgl.app.scene.SceneFactory;
import com.almasb.fxgl.core.math.FXGLMath;
import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.localization.Language;
import com.leo.ui.TestLoadingScene;
import com.leo.ui.TestMainMenu;
import javafx.geometry.Rectangle2D;
import javafx.scene.shape.Rectangle;

/**
 * @Author: wangss
 * @CreateTime: 2023-06-13  21:41
 * @Description: 添加中文
 */
public class LanuageApp extends GameApplication {
    @Override
    protected void initSettings(GameSettings settings) {
        settings.setMainMenuEnabled(true);
        settings.getSupportedLanguages().add(Language.CHINESE);
        settings.setDefaultLanguage(Language.CHINESE);

        // 自定义游戏界面
        settings.setSceneFactory(new SceneFactory() {
            @Override
            public FXGLMenu newMainMenu() {
                return new TestMainMenu();
            }

            // 自定义加载动画
            @Override
            public LoadingScene newLoadingScene() {
                return new TestLoadingScene();
            }
        });
    }

    @Override
    protected void initGame() {
        for (int i = 0; i < 50000; i++) {
            FXGL.entityBuilder()
                    .at(FXGLMath.randomPoint(new Rectangle2D(0, 0, 800, 600)))
                    .view(new Rectangle(2, 2, FXGLMath.randomColor()))
                    .buildAndAttach();
        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}
